"use strict";
cc._RF.push(module, 'e12aa6jtnVESIc7NPcPr7Ee', 'Start');
// Script/Start.js

"use strict";

// Learn cc.Class:
//  - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
window.step = 1;
window.stepstatus = -1;
window.waittime = '';
window.waitminutes = 0;
window.isShow = 0;
window.nowstep = 0;
window.nextstep = 0;
window.errormsg = '别乱点，再想想该干嘛了！';
window.url = 'http://118.25.108.137:8079/api/ServerTransform/';
window.seturl = 'http://118.25.108.137:8079/api/ServerSetData/'; // window.url='http://192.168.8.101:8079/api/ServerTransform/';
// window.seturl='http://192.168.8.101:8079/api/ServerSetData/';

cc.Class({
  "extends": cc.Component,
  properties: {
    scene: 1,
    speed: 1,
    is_start: false,
    m_login: [cc.Node]
  },
  // LIFE-CYCLE CALLBACKS:
  onLoad: function onLoad() {
    //获取参数
    var url = window.location.href;
    var loc = url.substring(url.lastIndexOf('/') + 1, url.length); // alert("loc="+loc);  
    //cc.log(loc);

    cc.director.preloadScene("Main", function () {
      cc.log("Next scene preloaded");
    });
  },
  startClick: function startClick(event, customEventData) {
    // //这里 event 是一个 Touch Event 对象，你可以通过 event.target 取到事件的发送节点
    // var node = event.target;
    // var button = node.getComponent(cc.Button);
    // //这里的 customEventData 参数就等于你之前设置的 "click2 user data"
    // cc.log("node=", node.name, " event=", event.type, " data=", customEventData);
    this.is_start = !this.is_start;
    cc.director.loadScene('Main');
  },
  // start () {
  // },
  update: function update(dt) {
    if (this.is_start) {
      this.m_login[2].zIndex = -10;
      this.m_login[0].zIndex = 100;
      this.m_login[1].zIndex = 90;
      var LoadingInfo = this.m_login[0].getComponent(cc.Label);
      var progressBar = this.m_login[0].getChildByName('startBar').getComponent(cc.ProgressBar);

      this._updateProgressBar(progressBar, LoadingInfo, dt);
    }
  },
  _updateProgressBar: function _updateProgressBar(progressBar, LoadingInfo, dt) {
    // cc.log(dt);
    // cc.log(this.speed);
    // cc.log(progress);
    //Label.string="加载场景"+this.cj+"...";
    var progress = progressBar.progress;

    if (progress < 1.0 && this._ping) {
      progress += dt * this.speed * 0.1;
    } else {
      this.scene = this.scene + 1;
      progress = 0;
      LoadingInfo.string = "加载场景" + this.scene + "...";
      this._ping = progress <= 0;
    }

    progressBar.progress = progress;
  } // update (dt) {},

});

cc._RF.pop();